﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace View
{
    public partial class MainFrm : BaseForm
    {
 

        public MainFrm()
        {
            InitializeComponent();
        }

        private void MainFrm_Load(object sender, EventArgs e)
        {
            btnSelect_Click(null, null);
        }

        #region 刷新。退出---按钮Click

        private void btnSelect_Click(object sender, EventArgs e)
        {
            string[] SQLSs=new string[]
            {
                "SELECT GUID,CONNECTIONSTRING FROM DATASOURCE WHERE ISDELETE = 0",
                "SELECT GUID,ITEMID,NAME,DATASOURCE_GUID,COMMANDTEXT,DESCRIPTION,CREATETIME,MODIFYTIME FROM COMMAND WHERE ISDELETE = 0",
                "SELECT GUID,COMMAND_GUID,TYPE,PARAMETERNAME,DESCRIPTION,CREATETIME,MODIFYTIME FROM COMMANDPARAMETER WHERE ISDELETE = 0",
                "SELECT GUID,USERIP_GUID,COMMAND_GUID,CREATETIME,MODIFYTIME FROM AUTHORIZATION WHERE ISDELETE = 0",
                "SELECT GUID,IP,LICENCE,DESCRIPTION,CREATETIME,MODIFYTIME FROM USERIP WHERE ISDELETE = 0"
            };
            DataSet ds = BLL.MyOracleHelper.ExecuteSet(BLL.Control.getConn(), SQLSs);
            if (ds.Tables.Count == 5)
            {
                dataGridView1.DataSource = ds.Tables[0];
                dataGridView2.DataSource = ds.Tables[1];
                dataGridView3.DataSource = ds.Tables[2];
                dataGridView4.DataSource = ds.Tables[3];
                dataGridView5.DataSource = ds.Tables[4];


                dataGridView1.Columns[0].DefaultCellStyle.BackColor = Color.Purple;
                dataGridView2.Columns[3].DefaultCellStyle.BackColor = Color.Purple;

                dataGridView3.Columns[1].DefaultCellStyle.BackColor = Color.Orange;
                dataGridView2.Columns[0].DefaultCellStyle.BackColor = Color.Orange;
                dataGridView4.Columns[2].DefaultCellStyle.BackColor = Color.Orange;

                dataGridView4.Columns[1].DefaultCellStyle.BackColor = Color.Navy;
                dataGridView5.Columns[0].DefaultCellStyle.BackColor = Color.Navy;

            }
            setGridView(dataGridView1, dataGridView2, dataGridView3, dataGridView4, dataGridView5);

        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        #endregion

        #region Set样式

        public void setGridView(params DataGridView[] dgs)
        {
            foreach (DataGridView dgv in dgs)
            {
                
            }
        }

        #endregion

        private void btnRun_Click(object sender, EventArgs e)
        {
            SingleFrm sf = new SingleFrm();
            sf.ShowDialog();
        }
    }
}
